gh-122575: Include sys.flags.gil as a sequence attribute#122576
gh-122575: Include sys.flags.gil as a sequence attribute#122576colesbury wants to merge 3 commits intopython:mainfrom
sys.flags.gil as a sequence attribute#122576Conversation
Make sure that `sys.flags.gil` is included when `sys.flags` is treated as a tuple or named tuple.
|
@ericsnowcurrently, when you have some time, I'd appreciate your review on this |
| * - .. attribute:: flags.warn_default_encoding | ||
| - :option:`-X warn_default_encoding <-X>` | ||
|
|
||
| * - .. attribute:: flags.gil |
There was a problem hiding this comment.
You should explain that the gil takes values 0, 1, or 2 and possibly explain the corresponding values (or a link to them) (and also say that None means the free-threaded build (if I'm not wrong)).
There was a problem hiding this comment.
This isn't the right place for that, is it?
There was a problem hiding this comment.
Oh actually I don't really know where it would be the right place... I just wanted to point it out since a new variable is being documented (I don't know whether there already exists another place so feel free to ignore this comment!)
| attr_types = { | ||
| "dev_mode": bool, | ||
| "safe_path": bool, | ||
| "gil": (int, type(None)), |
There was a problem hiding this comment.
Does the None value mean that it's the free-threaded build or is it for something else?
|
Potentially, .. data:: flags
The :term:`named tuple` *flags* exposes the status of command line
flags. The attributes are read only.
+ The number of flags may change in any version of Python,
+ do not unpack ``sys.flags`` or index into it as a tuple.which would document that we change A |
vstinner
left a comment
There was a problem hiding this comment.
LGTM if you apply the Py_ARRAY_LENGTH() suggestion.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
Ah, you should now update test_pythontypes() of test_sys. |
|
I'm going to close this for now as @encukou expressed concerns about backwards compatibility on the issue: #122575 (comment) |
Make sure that
sys.flags.gilis included whensys.flagsis treated as a tuple or named tuple.sys.flags.gilshould be a "sequence" attribute #122575📚 Documentation preview 📚: https://cpython-previews--122576.org.readthedocs.build/en/122576/library/sys.html#sys.flags